﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;

namespace WebServiceClient
{
    public partial class RunForm : Form
    {
        private static Helpers help = new Helpers();
        private static AlgorithmExecute algEx = new AlgorithmExecute();

        private List<string> getPar(string str)
        {
            string reg = @"\d+";
            Regex regex = new Regex(reg);
            Match match = regex.Match(str);
            List<string> tmp = new List<string>();
            while (match.Success)
            {
                tmp.Add(match.Value);
                match = match.NextMatch();
            }
            return tmp;
        }

        private List<string> getFloatPar(string str)
        {
            string reg = @"[\d\.]+";
            Regex regex = new Regex(reg);
            Match match = regex.Match(str);
            List<string> tmp = new List<string>();
            while (match.Success)
            {
                tmp.Add(match.Value);
                match = match.NextMatch();
            }
            return tmp;
        }

        public RunForm()
        {
            InitializeComponent();
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            Hide();
        }

        private void buttonRun_Click(object sender, EventArgs e)
        {
            List<string> intPar = getPar(textBox1.Text);
            List<string> floatPar = getFloatPar(textBox2.Text);
            labelResult.Text = algEx.Run(Form1.Login, Form1.Password, Form1.Name, intPar, floatPar);
        }
    }
}
